package phone.qyg.com.qyg.model.baidu;

import android.os.Parcel;
import android.os.Parcelable;

import com.baidu.mapapi.search.route.DrivingRouteLine;
import com.baidu.mapapi.search.route.MassTransitRouteLine;
import com.baidu.mapapi.search.route.PlanNode;

import java.util.List;

//import com.baidu.mapapi.search.route.MassTransitRouteLine;


/**
 * //class com.baidu.mapapi.search.route.DrivingRouteLine
 // com.baidu.mapapi.search.core.TransitBaseInfo cannot be cast to com.baidu.mapapi.search.core.b
 */

/**
 * 作者：lblbh on 2017/6/6 18:25
 * 邮箱：lanbuhan@163.com
 * 功能：线路详细信息
 */
public class LineInfo implements Parcelable {


    public int item;          //公交点击positon 使用
    public int walk;          //步行（单位：米）
    public int type;          //0-公交 1-驾车
    public int localType;     //0-普通情况 1-本地地图
    public int distance;      //距离（单位：米）
    public int duration;      //耗时 (单位：秒)
    public String title;      //名称
    public String line_name;  //线路名称
    public PlanNode tranEndNode;//线路结束位置
    public PlanNode tranStarNode;//线路开始位置
    public List<String> lineDetail; //线路对应描述信息
    public MassTransitRouteLine massTransitRouteLine;
    public DrivingRouteLine drivingRouteLine;


    public LineInfo() {}

    @SuppressWarnings("unchecked")
    public LineInfo(Parcel in) {
        item = in.readInt();
        walk = in.readInt();
        type = in.readInt();
        distance = in.readInt();
        duration = in.readInt();
        title = in.readString();
        line_name = in.readString();
        lineDetail = in.readArrayList(String.class.getClassLoader());
        massTransitRouteLine = in.readParcelable(MassTransitRouteLine.class.getClassLoader());
        drivingRouteLine = in.readParcelable(DrivingRouteLine.class.getClassLoader());

        tranEndNode = in.readParcelable(PlanNode.class.getClassLoader());
        tranStarNode = in.readParcelable(PlanNode.class.getClassLoader());
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(item);
        dest.writeInt(walk);
        dest.writeInt(type);
        dest.writeInt(distance);
        dest.writeInt(duration);
        dest.writeString(title);
        dest.writeString(line_name);
        dest.writeList(lineDetail);
        dest.writeParcelable(massTransitRouteLine, flags);
        dest.writeParcelable(drivingRouteLine, flags);

        dest.writeParcelable(tranEndNode, flags);
        dest.writeParcelable(tranStarNode, flags);

    }

    public static final Creator<LineInfo> CREATOR = new Creator<LineInfo>() {
        @Override
        public LineInfo[] newArray(int size) {
            return new LineInfo[size];
        }

        @Override
        public LineInfo createFromParcel(Parcel in) {
            return new LineInfo(in);
        }
    };

    @Override
    public String toString() {
        return "LineInfo{" +
                "distance=" + distance +
                ", duration=" + duration +
                ", walk=" + walk +
                ", line_name='" + line_name + '\'' +
                ", lineDetail=" + lineDetail +
                '}';
    }
}
